<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link href="../../../static/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../../../static/js/jquery.js"></script>
<script type="text/javascript" src="../../../static/js/getParameter.js"></script>
<script type="text/javascript">
  let user = JSON.parse(localStorage.getItem("user"));
  $(function () {
    var purchaseid = getParameter("purchaseid");
    queryPurchaseViewPE(purchaseid);
  })

  function queryPurchaseViewPE(purchaseid) {
    $.ajax({
      url: "/purchase/queryPurchaseDetails",
      method: "post",
      dataType: "json",
      data: {purchaseId: purchaseid},
      success: function (pb) {
        console.log(pb);
        $('#cpe_Pid').html(pb.data.purchaseId);
        $('#cpe_Ptime').html(pb.data.purchaseTime);
        $('#cpe_Tmoney').html(pb.data.totalMoney);
        $('#cpe_CreateName').html(pb.data.creatName);
        var details = pb.data.purchaseDatails;
        details.forEach(function (item,index) {
          let detail =
                  '<tr>' +
                  ' <td>'+(index+1)+'</td>' +
                  ' <td>'+item.brand+'</td>' +
                  ' <td>'+item.type+'</td>' +
                  ' <td>'+item.model+'</td>' +
                  ' <td>'+item.firm+'</td>' +
                  ' <td>'+item.count+'</td>' +
                  ' <td>'+item.unit+'</td>' +
                  ' <td>'+item.purchasePrice+'</td>' +
                  ' <td>'+item.totalMoney+'</td>' +
                  ' </tr>';
          $('#cpe_Details').append(detail);
        })
      }
    })
  }
function updatePurchaseExamine() {
    var purchaseId = getParameter("purchaseid");
    var time = new Date();
    let checkTime = time.toLocaleString();
    var checkOpinion = $("#cpe_Opinion").val();
    var checkId = user.uid;
    var checkStatus = $("#cpe_Status").val()
    var isTrue = confirm("是否提交");
  if (isTrue) {
    $.ajax({
      url: "/purchase/updatePurchase",
      method: "post",
      data:{purchaseId:purchaseId,checkId:checkId,checkTime:checkTime,checkStatus:checkStatus,checkOpinion:checkOpinion},
      dataType: "JSON",
      success: function (rel) {
        if (rel.data) {
          window.location.href = "lists";
        }
      }
    })
  }
}

</script>
</head>
<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>采购单审核</li>
    <li>审核</li>
  </ul>
</div>
<div class="formbody">
  <div class="formtitle"><span>采购单审核</span></div>
  <ul class="forminfo">
    <li>
      <label>采购单编号</label>
      <cite id="cpe_Pid">CG201711180001</cite>
    </li>
    <li>
      <label>采购购时间</label>
      <cite id="cpe_Ptime">2017-11-18 15:36:10</cite>
    </li>
    <li>
      <label>总金额</label>
       <cite id="cpe_Tmoney">￥9,876,582</cite>
    </li>
    <li>
      <label>操作人</label>
      <cite id="cpe_CreateName">关羽</cite>
    </li>
  </ul>
  <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>品牌</th>
          <th>类型</th>
          <th>型号</th>
          <th>厂商</th>
          <th>数量</th>
          <th>单位</th>
          <th>单价</th>
          <th>金额</th>
        </tr>
      </thead>
      <tbody id="cpe_Details">
        <tr>
          <td>1</td>
          <td>联想</td>
          <td>笔记本电脑</td>
          <td>T470</td>
          <td>北京联想科技股份有限公司</td>
          <td>10</td>
          <td>台</td>
          <td>9998</td>
          <td>99980</td>
        </tr>
        <tr>
          <td>2</td>
          <td>联想</td>
          <td>笔记本电脑</td>
          <td>X260</td>
          <td>北京联想科技股份有限公司</td>
          <td>5</td>
          <td>台</td>
          <td>5500</td>
          <td>27500</td>
        </tr>
      </tbody>
  </table>
  <ul class="forminfo">
    <li>
      <label>审核意见</label>
      <textarea id="cpe_Opinion" class="textinput"></textarea>
    </li>
    <li>
      <label>审核状态</label>
      <select id="cpe_Status" class="dfselect">
          <option value="">请选择</option>
          <option value="3">通过</option>
          <option value="4">不通过</option>
      </select>
    </li>
    <li>
      <label>&nbsp;</label>
      <input name="" type="button" class="btn" value="审核" onclick="updatePurchaseExamine()"/>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      <input name="" type="button" class="btn" value="返回" onclick="window.location.href='lists'"/>
    </li>
  </ul>
</div>
<script type="text/javascript">
	$('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
